$(function (){
    //密码输入框type转换
    let display = true;
    $('.passNone').click(()=>{
        if(display){
            $('.passNone').attr("src","../../images/disblock.png");
            $('.password').attr("type","text")
        }else{
            $('.passNone').attr("src","../../images/disnone.png");
            $('.password').attr("type","password")
        }
        display =!display
    });

    $('.sign').click(()=>{
        let userName = $('#username').val(),
            passWord = $('#password').val();
        if(userName=="" || passWord==""){
            $('.inf-body').css("display","block");
            $('.inf-error').html("用户名或密码不得为空");
        }else{
            let signLogin;
            signLogin = Interceptor('/login','post',{
                "userName":userName,
                "password":passWord
            })
            switch (signLogin.code){
                case 4000:
                    $('.inf-body').css("display","block");
                    $('.inf-error').html("用户名或密码错误");
                    break;
                case 200:
                    sessionStorage.setItem("Authorization", signLogin.data.token);
                    sessionStorage.setItem("UserName", userName);
                    $('.inf-body').css("display","none");
                    break;
            }
            switch (signLogin["data"].role){
                case '0':
                    $('.sign').attr("href","../userIndex/userIndex.html");
                    sessionStorage.setItem("success", "1");
                    sessionStorage.setItem("jurisdiction", "0");
                    console.log(signLogin)
                    break;
                case '1':
                    $('.sign').attr("href","../adminIndex/adminIndex.html");
                    sessionStorage.setItem("success", "1");
                    sessionStorage.setItem("jurisdiction", "1");
                    break;
            }


            console.log(signLogin);
        }
    })
})